﻿using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Content;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace GameStateManagement
{
    public class HighScoreManager : DrawableGameComponent
    {
        private SpriteBatch m_kSpriteBatch;
        private SpriteFont m_kFont;

        private Vector2 m_vPosition;

        public HighScoreManager(Game game, Vector2 vPosition)
            : base(game)
        {
            m_vPosition = vPosition;

            // Make this draw over the asteroids and ship.
            DrawOrder = 1000;
        }

        protected override void LoadContent()
        {
            IGraphicsDeviceService graphicsService = (IGraphicsDeviceService)this.Game.Services.GetService(typeof(IGraphicsDeviceService));

            m_kSpriteBatch = new SpriteBatch(graphicsService.GraphicsDevice);
            m_kFont = Game.Content.Load<SpriteFont>("fpsfont");

            base.LoadContent();
        }

        protected override void UnloadContent()
        {
            base.UnloadContent();
        }

        public override void Draw(GameTime gameTime)
        {
            if (!GameplayScreen.pause)
            {
                m_kSpriteBatch.Begin(SpriteSortMode.Immediate, BlendState.AlphaBlend);


                // Color this based on the framerate
                Color DrawColor = Color.Green;
                m_kSpriteBatch.DrawString(m_kFont, "Score: " + GameplayScreen.currentScore.ToString("f3"), m_vPosition, DrawColor);
                m_kSpriteBatch.End();
            }
            base.Draw(gameTime);
        }

        public void resetScore()
        {
            GameplayScreen.currentScore = 0;
        }
    }
}
